<?php 
$con = mysql_connect("localhost","root","S4PS1L");
$bd = mysql_select_db("db_sapsil",$con);

require_once ('../../lib/utils.php');
$genero = $_GET['genero'];
$estado = $_GET['tipo_rep'];
$fecha1 = fechaguardar($_GET['fecha1']);
$fecha2 = fechaguardar($_GET['fecha2']);

$query_grafic = "SELECT  CF.CTIF_NOMBRE, COUNT(CF.CTIF_NOMBRE) AS CANT
FROM PERSONA PER, PERSONAS_CON_DISCAPACIDAD PCD, 
EXPEDIENTE EXPE, FORMACION_REALIZADA FR,CAT_TITULO_FORMACION CT, 
CAT_TIPO_FORMACION CF
WHERE PCD.PER_CODIGO = PER.PER_CODIGO
AND FR.EXP_CODIGO = EXPE.EXP_CODIGO
AND EXPE.EXP_CODIGO = PCD.EXP_CODIGO
AND FR.CTFO_CODIGO = CT.CTFO_CODIGO
AND CT.CTIF_CODIGO = CF.CTIF_CODIGO
AND PER.PER_GENERO = '$genero'
AND EXPE.CEF_CAE_CODIGO = '$estado'
AND EXPE.EXP_FECHA_CREACION BETWEEN '$fecha1' AND DATE_ADD('$fecha2', INTERVAL 1 DAY)
GROUP BY CF.CTIF_NOMBRE";

$grafic = mysql_query($query_grafic);
 // content="text/plain; charset=utf-8"
require_once ('../../clase/jpgraph/jpgraph.php');
require_once ('../../clase/jpgraph/jpgraph_pie.php');
require_once ('../../clase/jpgraph/jpgraph_pie3d.php');
 
$datay=array();
$labelx=array();
 
while ($row_grafic = mysql_fetch_array($grafic)) {
$labelx[] = $row_grafic["CTIF_NOMBRE"];
$datay[] = $row_grafic["CANT"];
}
 
$data = $datay;
$graph = new PieGraph(1200,800);
$graph->img->SetAntiAliasing();
$graph->SetMarginColor('black');
$graph->SetShadow();

$graph->title->Set('Reporte inicio de formacion por genero y tipo de formacion');
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,30);
$graph->title->SetColor("white");

$p1 = new PiePlot3D($data);
$p1->SetAngle(20);
$p1->SetSize(0.5);
$p1->SetCenter(0.5);
$p1->SetLegends($labelx);
 


$p1->SetLegends($labelx); 
 
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_ARIAL,FS_BOLD,25);
$p1->value->SetColor("white");
$p1->SetLabelPos(0.5);
// Explode all slices
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();
 
mysql_free_result($grafic);
?>